package com.zbs.framework.swagger.utils.excel;

import lombok.Getter;

import java.util.List;
import java.util.Objects;

@Getter
public class EasyModel {
    // 开始行号
    private Integer firstRow;
    // 结束行号
    private Integer lastRow;
    // 开始列
    private Integer firstCol;
    // 结束列
    private Integer lastCol;
    // 内容
    private Object val;
    // 下拉列表值
    private List<String> boxList;
    // 高
    private Integer height;
    // 宽
    private Integer width;
    // 是否是图片
    private Boolean isImage;
    // 样式唯一标识
    private String styleKey;
    // url  地址
    private String url;
    // 路径
    private String path;

    // 列默认样式
    private boolean defaultColumnStyle = false;

    public static EasyModel create(Integer firstRow,Integer lastRow,Integer firstCol,Integer lastCol,Object val){
        if (Objects.equals(lastRow, firstRow) && Objects.equals(lastCol, firstCol)) {
            lastRow = null;
            lastCol = null;
        }
        return new EasyModel().firstRow(firstRow).lastRow(lastRow).firstCol(firstCol).lastCol(lastCol).val(val);
    }

    public static EasyModel createFirstCol(Integer firstRow,Integer lastRow,Integer firstCol,Object val){
        Integer lastCol = firstCol;
        if (Objects.equals(lastRow, firstRow)) {
            lastRow = null;
            lastCol = null;
        }
        return new EasyModel().firstRow(firstRow).lastRow(lastRow).firstCol(firstCol).lastCol(lastCol).val(val);
    }

    public static EasyModel createFirstRow(Integer firstRow,Integer firstCol,Integer lastCol,Object val){
        Integer lastRow = firstRow;
        if (Objects.equals(lastCol, firstCol)) {
            lastRow = null;
            lastCol = null;
        }
        return new EasyModel().firstRow(firstRow).lastRow(lastRow).firstCol(firstCol).lastCol(lastCol).val(val);
    }

    public static EasyModel create(Integer firstRow,Integer firstCol,Object val){
        return new EasyModel().firstRow(firstRow).firstCol(firstCol).val(val);
    }

    public static EasyModel createBox(Integer firstRow,Integer firstCol,List<String> boxList){
        return new EasyModel().firstRow(firstRow).firstCol(firstCol).boxList(boxList);
    }

    public static EasyModel createUrlImage(Integer firstRow,Integer lastRow,Integer firstCol,Integer lastCol,String url){
        return new EasyModel().firstRow(firstRow).lastRow(lastRow).firstCol(firstCol).lastCol(lastCol).url(url).isImage(true);
    }

    public static EasyModel createPathImage(Integer firstRow,Integer lastRow,Integer firstCol,Integer lastCol,String path){
        return new EasyModel().firstRow(firstRow).lastRow(lastRow).firstCol(firstCol).lastCol(lastCol).path(path).isImage(true);
    }

    public static EasyModel createPathImage(Integer firstRow,Integer firstCol,String path){
        return new EasyModel().firstRow(firstRow).lastRow(firstRow).firstCol(firstCol).lastCol(firstCol).path(path).isImage(true);
    }


    public static EasyModel createUrlImage(Integer firstRow,Integer firstCol,String url){
        return new EasyModel().firstRow(firstRow).lastRow(firstRow).firstCol(firstCol).lastCol(firstCol).url(url).isImage(true);
    }

    private EasyModel boxList(List<String> boxList) {
        this.boxList = boxList;
        return this;
    }

    public EasyModel defaultColumnStyle(boolean defaultColumnStyle) {
        this.defaultColumnStyle = defaultColumnStyle;
        return this;
    }

    public EasyModel height(Integer height) {
        this.height = height;
        return this;
    }

    public EasyModel styleKey(String styleKey) {
        this.styleKey = styleKey;
        return this;
    }

    public EasyModel width(Integer width) {
        this.width = width;
        return this;
    }

    public EasyModel isImage(boolean isImage) {
        this.isImage = isImage;
        return this;
    }

    public EasyModel firstRow(Integer firstRow) {
        this.firstRow = firstRow;
        return this;
    }

    public EasyModel lastRow(Integer lastRow) {
        this.lastRow = lastRow;
        return this;
    }

    public EasyModel firstCol(Integer firstCol) {
        this.firstCol = firstCol;
        return this;
    }

    public EasyModel lastCol(Integer lastCol) {
        this.lastCol = lastCol;
        return this;
    }

    public EasyModel val(Object val) {
        this.val = val;
        return this;
    }

    public EasyModel url(String url) {
        this.url = url;
        return this;
    }

    public EasyModel path(String path) {
        this.path = path;
        return this;
    }
}
